package talent.controller;

import jakarta.annotation.security.PermitAll;
import talent.dto.RecommendationRequestDTO;
import talent.dto.StudentActivityRequestDTO;
import talent.dto.TalentQueryDTO;
import talent.service.TalentService;
import talent.vo.RecommendationVO;
import talent.vo.TalentVO;
import lombok.RequiredArgsConstructor;

import org.springframework.web.bind.annotation.*;


import java.util.List;

@RestController
@RequestMapping("/api/talent")
@RequiredArgsConstructor
//@Anonymous
public class TalentController {

    private final TalentService talentService;

    @PostMapping("/recommend")
    @PermitAll
    public List<RecommendationVO> recommendTalents(@RequestBody TalentQueryDTO queryDTO) {
        System.out.println(talentService.recommendTalents(queryDTO));
        return talentService.recommendTalents(queryDTO);
    }


    @PostMapping("/optimal")
    @PermitAll
//    @PreAuthorize("hasRole('HR')") // 全局角色控制
    public List<TalentVO> findOptimalTalents(@RequestBody RecommendationRequestDTO requestDTO) {
        return talentService.findOptimalTalents(requestDTO);
    }


    //查询学生详情
    @GetMapping("/{id}")
    @PermitAll
//    @PreAuthorize("hasRole('HR')") // 全局角色控制
    public TalentVO getTalentDetails(@PathVariable Long id) {
        return talentService.getTalentDetails(id);
    }

    //查询最活跃的学生
    @GetMapping("/top")
    public List<TalentVO> getTopTenStudents() {
        System.out.println(talentService.getTopTenStudents());
        return talentService.getTopTenStudents();
    }


//    @PostMapping("/top-active-students")
//    @PermitAll
//    public List<TalentVO> getTopActiveStudents(@RequestBody StudentActivityRequestDTO requestDTO) {
//        return talentService.getTopActiveStudents(requestDTO);
//    }
}
